package com.su.controller;

import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.su.tools.DaoSupport1;
import com.su.tools.PageData;
import com.su.util.Page;
import net.sf.json.JSONObject;
import net.sf.json.JSONArray;

@Service("dictService")
public class DictService {

	@Resource(name = "daoSupport1")
	private DaoSupport1 dao;
	private JSONObject json = new JSONObject();
	private PageData retPd;
	private List<PageData> retListPd;

	public JSONObject invoke(PageData pd) throws Exception {
		
		if (pd.getString("params").equals("D101")) {
			this.D101(pd);
		} else if (pd.getString("params").equals("D102")) {
			this.D102(pd);
		} else {
			json.put("code", "100");
			json.put("msg", "没有找到该业务代码");
			return json;
		}
		return json;
	}

	/**
	 * 获取字典，用于初始化combobox
	 * @param pd
	 * @throws Exception
	 */
	private void D101(PageData pd) throws Exception {
		retListPd = dao.getList("DictMapper.getByParent", pd);
		if(retListPd.size()>0){
			json.put("status", "true");
			json.put("record", retListPd);
		}else{
			json.put("status", "false");
			json.put("record", "");
		}
		
	}

	/**
	 * 
	 * @param pd
	 * @throws Exception
	 */
	private void D102(PageData pd) throws Exception {
		return;
	}
		
}